package com.tj.jinzao.presenter;


import android.util.Log;

import com.tj.jinzao.api.SubscriberCallBack;
import com.tj.jinzao.base.BasePresenter;
import com.tj.jinzao.base.IBaseView;
import com.tj.jinzao.manager.UserManager;
import com.tj.jinzao.model.Health;
import com.tj.jinzao.model.ResultResponse;

import java.util.List;

/**
 * 健康报告处理
 * Created by wjy 2018/12/10.
 */
public class HealthPresenter extends BasePresenter<IBaseView<List<Health>>> {

    public HealthPresenter(IBaseView<List<Health>> view) {
        super(view);
    }

    public void getHealthList(long familyId,Long uid) {
        long uId = UserManager.getInstance().getUser().getId();
        Log.w("数据接收结果aaa","--"+uId+"==="+familyId);
        addSubscription(familyId == 0 ? mApiService.getHealthReportList(uid)
                        : mApiService.getHealthReportList(uid, familyId)
                , new SubscriberCallBack<List<Health>>(mView.getContext()) {
                    @Override
                    protected void onSuccess(List<Health> list) {
                        Log.w("数据接收结果aaa","qqqq");
                        if (mView != null) mView.onRequestSuccess(list);
                    }

                    @Override
                    protected void onFailure(ResultResponse response) {
                        Log.w("数据接收结果aaa","wwww");
                        if (mView != null) mView.onRequestError(response.getMessage());
                    }

                    @Override
                    protected boolean isShowProgress() {
                        return true;
                    }
                });
    }
}